﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MadLibrary.Web
{
    /// <summary>
    /// Holds and manages complete website.
    /// </summary>
    public class WebSite
    {
        /// <summary>
        /// Gets or sets path to root directory.
        /// </summary>
        public string PathToRoot { get; set; }
        /// <summary>
        /// Gets or sets root directory of current website.
        /// </summary>
        public WebDirectory Root { get; set; }
        /// <summary>
        /// Creates new empty website.
        /// </summary>
        public WebSite()
        {
            this.Root = new WebDirectory();
        }
        /// <summary>
        /// Creates new website and loads it from specified path.
        /// </summary>
        /// <param name="PathToRoot">Specifies path to root document.</param>
        public WebSite(string PathToRoot)
        {
            this.Root = new WebDirectory();
            this.Root.LoadContent(PathToRoot);
        }
        /// <summary>
        /// Creates new web site with specified root directory and its path.
        /// </summary>
        /// <param name="Root">Specifies root directory of new website.</param>
        /// <param name="PathToRoot">Specifies path to root directory of new website.</param>
        public WebSite(WebDirectory Root, string PathToRoot)
        {
            this.Root = Root;
            this.PathToRoot = PathToRoot;
        }
        /// <summary>
        /// Select HTML document from current web site by specified HTTP call path.
        /// </summary>
        /// <param name="httpPath">Specifies HTTP call path to searched HTML document.</param>
        /// <returns>Selected HTML document on specified HTTP call path.</returns>
        public HtmlDocument GetPage(string httpPath)
        {
            return this.Root.GetPage(httpPath);
        }
        /// <summary>
        /// Selects CSS document from current web site by specified HTTP call path.
        /// </summary>
        /// <param name="httpPath">Specifies HTTP call path to searched CSS document.</param>
        /// <returns>Selected CSS document on specified HTTP call path.</returns>
        public CssDocument GetStyles(string httpPath)
        {
            return this.Root.GetStyles(httpPath);
        }
    }
}
